<script lang="ts" setup>
  import { ref, createVNode } from 'vue';
  import { ExclamationCircleOutlined } from '@ant-design/icons-vue';
  import Button from '@sscd/button';
  import Modal from '@sscd/modal';
  const visible = ref<boolean>(false);
  const showModal = () => {
    visible.value = true;
  };
  const hideModal = () => {
    visible.value = false;
  };
  const confirm = () => {
    Modal.confirm({
      title: 'Confirm',
      icon: createVNode(ExclamationCircleOutlined),
      content: 'Bla bla ...',
      okText: '确认',
      cancelText: '取消',
      onOk: () => {
        // vue3.4+版本可能会出现Modal无法正常关闭，需调用Modal.remove()
        console.log('ok');
        Modal.remove();
      },
      onCancel: () => {
        // vue3.4+版本可能会出现Modal无法正常关闭，需调用Modal.remove()
        console.log('cancel');
        Modal.remove();
      },
    });
  };
</script>

<template>
  <div class="demo">
    <div class="demo-title">国际化</div>
    <div class="demo-content">
      <Button type="primary" @click="showModal">Modal</Button>
      <Button @click="confirm">Confirm</Button>
      <Modal
        v-model:visible="visible"
        title="Modal"
        ok-text="确认"
        cancel-text="取消"
        @ok="hideModal"
      >
        <p>Bla bla ...</p>
        <p>Bla bla ...</p>
        <p>Bla bla ...</p>
      </Modal>
    </div>
  </div>
</template>
